﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;

namespace OAO
{
    class KeyboardListener
    {
        private GameCtrl mGameCtrl;
        private ScreenCapture mScreenCapture;
        private bool mPressed;

        Thread mThreadMacroShunpo;

        public KeyboardListener()
        {
            mGameCtrl = new GameCtrl();
            mScreenCapture = new ScreenCapture();
        }

        public void OnKeyDownListener(object sender, KeyEventArgs e)
        {
            if (mPressed)
            {
                return;
            }
            switch (e.KeyData)
            {
                case Keys.G:
                    mPressed = true;
                    mGameCtrl.ShunpoReleased = false;
                    mGameCtrl.ShunpoCancled = false;
                    mThreadMacroShunpo = new Thread(new ThreadStart(mGameCtrl.MacroShunpo));
                    mThreadMacroShunpo.Priority = ThreadPriority.AboveNormal;
                    mThreadMacroShunpo.Start();
                    break;
            }
        }
        public void OnKeyUpListener(object sender, KeyEventArgs e)
        {
            switch (e.KeyData)
            {
                case Keys.G:
                    mGameCtrl.ShunpoReleased = true;
                    break;

                default:
                    return;
            }
            mPressed = false;
        }

        public void OnMouseEventListener(object sender, MouseEventArgs e)
        {
            mGameCtrl.ShunpoCancled = true;
        }
    }
}
